package com.liang.jiekou.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liang.jiekou.entity.INVMB;
import com.liang.jiekou.service.INVMBService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Api(tags = "物料品号控制器")
@RestController
@RequestMapping("/wl")
public class INVMBController {
    @Resource
    private INVMBService invmbService;

//查询物料品号信息
@ApiOperation("根据品号查询相关信息")
    @GetMapping("/selectINVMB")
    public INVMB selectINVMB( @RequestParam String MB001){
        return invmbService.selectINVMB(MB001);
    }

//    @ApiOperation("查询全部的物料信息")
//    @GetMapping("/selectINVMB/all")
//    public List<INVMB> selectINVMBall(){
//        return invmbService.select();
//    }


    @ApiOperation("查询全部的物料信息")
    @GetMapping("/selectINVMB/all")
    public ResponseEntity<IPage<Map<String, Object>>> selectINVMBall(@RequestParam Integer page, @RequestParam Integer pageSize,
     String startcreate, String endcreate, String startupdate, String endupdate
    ){
        Page<INVMB> paging = new Page<>(page, pageSize);

        IPage<Map<String, Object>> result = invmbService.select(paging,startcreate,endcreate,startupdate,endupdate);
        System.out.println(result);
        return ResponseEntity.ok().body(result);

    }


//    @ApiOperation("分页查询物料信息")
//    @GetMapping("/selectINVMB/page")
//    public List<Map<String, Object>> selectINVMBByPage(@RequestParam int page, @RequestParam int size) {
//        return invmbService.selectByPage(page, size);
//    }

}
